home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_napster.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  628 b   |  44 lines

  1. /*
  2.   decode_napster.c
  3.  
  4.   Napster.
  5.  
  6.   w00w00!
  7.   
  8.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  9.  
  10.   $Id: decode_napster.c,v 1.1 2000/05/16 17:31:14 dugsong Exp $
  11. */
  12.  
  13. #include <sys/types.h>
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include "decode.h"
  17.  
  18. int
  19. decode_napster(u_char *buf, int len)
  20. {
  21.     u_short i, type;
  22.     
  23.     if (len < 4) return (0);
  24.     
  25.     i = pletohs(buf);
  26.     type = pletohs(&buf[2]);
  27.     
  28.     if (type != 2) return (0);
  29.     if (i > len - 4) return (0);
  30.     
  31.     buf[4 + i] = '\0';
  32.     
  33.     strlcpy(Buf, buf + 4, sizeof(Buf));
  34.     strlcat(Buf, "\n", sizeof(Buf));
  35.     
  36.     i = strlen(Buf);
  37.     
  38.     if (!is_ascii_string(Buf, i))
  39.         return (0);
  40.     
  41.     return (i);
  42. }
  43.  
  44.